package org.bhavani.binarysearch;

public class BinaryDriver {


	public int Binary(int[] search ,int find ){

		int start,end,midpt;

		start = 0;
		end = search.length -1 ;
		while (start <= end) {

			midpt = (start + end) / 2 ;

			if (find == search[
			                   midpt]) {

				

				return midpt;
			} else if (find > midpt) {
				start = midpt+1;
			} else {
				end = midpt-1;
			}

		}

		return -1;

	}
	public static void main(String[] args) {
		int [] search = {1,2,3,4,5,6,7};
		int find = 7;
		BinaryDriver driver =new BinaryDriver();
		int index = driver.Binary(search, find);
		System.out.println("The element is found in the index "+index);
	}

}

